package com.campus.controller;

import com.campus.entry.ManagerClass;
import com.campus.response.ResponseResult;
import com.campus.response.ResultCode;
import com.campus.service.ManagerClassService;
import com.campus.service.TeacherStudentInClassService;
import io.swagger.v3.oas.models.security.SecurityScheme;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/class")
public class ManagerClassController {
    @Autowired
    private ManagerClassService managerClassService;
    @Autowired
    private TeacherStudentInClassService teacherStudentInClassService;
    @PostMapping("/save")
    public ResponseResult<Object> saveManagerClass(@RequestBody ManagerClass managerClass){
        managerClassService.createClass(managerClass);
        return new ResponseResult<>(ResultCode.ALL_SUCCESS,"null");
    }
    @PutMapping("/update")
    public ResponseResult<Object> updateManagerClass(@RequestBody ManagerClass managerClass){
        managerClassService.updateClass(managerClass);
        return new ResponseResult<>(ResultCode.ALL_SUCCESS,"null");
    }
    @PostMapping("/addTeacher")
    public ResponseResult<Object> addTeacher(@RequestParam Integer classId, @RequestParam Integer teacherId){
        managerClassService.addTeacher(classId,teacherId);
        return new ResponseResult<>(ResultCode.ALL_SUCCESS,"null");
    }
    @PostMapping("/addStudent")
    public ResponseResult<Object> addStudents(@RequestParam Integer classId,@RequestBody List<Integer> studentIds){
        teacherStudentInClassService.addStudent(classId,studentIds);
        return new ResponseResult<>(ResultCode.ALL_SUCCESS,"null");

    }

}
